package com.zzyl.nursing.mapper;

import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.domain.TimeBean;
import com.zzyl.nursing.dto.ReservationDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Mapper
public interface ReservationMapper {
    /**
     * 查询当天取消预约数量
     * @param startTime
     * @param endTime
     */
    @Select("select count(*) from reservation where status = 2 and update_by = #{userId} between #{startTime} and  #{endTime}")
    public Integer cancelledCount(@Param("userId") Long userId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime) ;


    /**
     * 查询指定日期内每个时间段的预约数量
     * @param start 当天开始时间
     * @param end 当天结束时间
     * @return 时间段和预约数量
     */
    List<TimeBean> countReservationsByDate(
            @Param("start") Date start,
            @Param("end") Date end
    );

    /**
     * 添加预约
     * @param reservation
     */
    void addReservation(Reservation reservation);

    /**
     * 查询预约列表
     * @param status 预约状态
     * @return 预约列表
     */
    List<Reservation> selectReservationList(Integer status);

    /**
     * 取消预约
     * @param id 预约ID
     */
    void cancelReservation(@Param("id") Long id,@Param("updateBy") Long updateBy,@Param("status") Integer status);
}
